﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace ProjectFitus.Models
{
    public class UserAndSpecialistCapsule
    {
        public User usr = new User();
        public Specialist speciali = new Specialist();


        //Uppá ef e-h fields er sleppt í view-inu.. t.d. admin specific fields.. also. UPDATE date.time logic in D.O.B
        public void insertFromFormCollection(FormCollection formData)
        {
            foreach (var i in formData.AllKeys)
            {
                switch (i)
                {
                    case "firstName":
                        if (string.IsNullOrWhiteSpace(formData[i]))
                        {
                            this.usr.firstName = null;
                        }
                        else
                        {
                            this.usr.firstName = formData[i];
                        }
                        break;
                    case "lastName":
                        if (string.IsNullOrWhiteSpace(formData[i]))
                        {
                            this.usr.lastName = null;
                        }
                        else
                        {
                            this.usr.lastName = formData[i];
                        }
                        break;
                    case "email":
                        //Add logic?
                        this.usr.email = formData[i];
                        break;
                    case "userName":
                        //Add logic?
                        this.usr.userName = formData[i];
                        break;
                    case "userDescription":
                        if (string.IsNullOrWhiteSpace(formData[i]))
                        {
                            this.usr.userDescription = null;
                        }
                        else
                        {
                            this.usr.userDescription = formData[i];
                        }
                        break;
                    case "country":
                        this.usr.country = formData[i];
                        break;
                    case "dateOfBirth":
                        //Add logic
                        this.usr.dateOfBirth = DateTime.Parse(formData[i]);
                        break;
                    case "profileImageUrl":
                        //Add logic (i.e. default pic if null? or just null if null?)
                        this.usr.profileImageUrl = formData[i];
                        break;
                    case "userIsActive":
                        this.usr.isActive = bool.Parse(formData[i]);
                        break;



                    case "professionId":
                        this.speciali.professionId = int.Parse(formData[i]);
                        break;
                    case "specialty":
                        if (string.IsNullOrWhiteSpace(formData[i]))
                        {
                            this.speciali.specialty = null;
                        }
                        else
                        {
                            this.speciali.specialty = formData[i];
                        }
                        break;
                    case "workEmail":
                        if (string.IsNullOrWhiteSpace(formData[i]))
                        {
                            this.speciali.workEmail = null;
                        }
                        else
                        {
                            this.speciali.workEmail = formData[i];
                        }
                        break;
                    case "workPhone":
                        if (string.IsNullOrWhiteSpace(formData[i]))
                        {
                            this.speciali.workPhone = null;
                        }
                        else
                        {
                            this.speciali.workPhone = formData[i];
                        }
                        break;
                    case "specialistIsActive":
                        this.speciali.isActive = bool.Parse(formData[i]);
                        break;
                    case "id":
                        break;
                }
            }
        }
    }
}